/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Util;



import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;


/**
 *
 * @author USER
 */
public class MySqlDataAccessHelper {
   private Connection connection;
   
   public void open(){
       
       try{
          
           DriverManager.registerDriver((new org.gjt.mm.mysql.Driver()));
           String url = "jdbc:mysql://localhost:3306/bookonlinev3";
           Properties info = new Properties();
           info.setProperty("user", "root");
           info.setProperty("password", "root");
           info.setProperty("characterEncoding", "UTF-8");
           connection =DriverManager.getConnection(url, info);
           
       }catch(Exception w){
           
       }
   }
   
   public void close(){
       try{
           this.connection.close();
       }
       catch(Exception e){
           
       }
   }
   
   public ResultSet executeQuery(String sql){
       ResultSet rs = null;
       
       try{
           Statement sm = this.connection.createStatement();
           rs = sm.executeQuery(sql);
       }catch(Exception e){
           
       }
       
       return rs;
   }
}
